package cn.virens.web.components.activiti;

import org.activiti.engine.ProcessEngine;
import org.springframework.beans.factory.FactoryBean;

public class ActivitiServiceFactoryBean implements FactoryBean<ActivitiService> {
	private ProcessEngine processEngine;
	private ActivitiService activitiService;

	public ActivitiServiceFactoryBean(ProcessEngine processEngine) {
		this.processEngine = processEngine;
	}

	@Override
	public ActivitiService getObject() throws Exception {
		if (activitiService == null) {
			activitiService = new ActivitiService(processEngine);
		}

		return activitiService;
	}

	@Override
	public Class<?> getObjectType() {
		return ActivitiService.class;
	}

	@Override
	public boolean isSingleton() {
		return true;
	}

}
